package com.harvey.coding.lambda.cart;

import cn.hutool.core.collection.ListUtil;
import com.google.common.collect.Lists;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class ListGenerator<T> {
    /**
     * 使用内部类实例化的方式进行初始化
     *
     * @return
     */
    public List<T> generateByCurlyBracket(T element) {
        List<T> res = new ArrayList<T>() {{
            add(element);
        }};
        return res;
    }

    public List<T> generateByAsList(T ... element) {
        List<T> res = Arrays.asList(element);
        return res;
    }

    public List<T> generateBySteam(T ... element) {
        return Stream.of(element).collect(Collectors.toList());
    }

    public List<T> generateByGuava(T ... element) {
        return Lists.newArrayList(element);
    }

    public List<T> generateByHutoolList(T ... element) {
        return ListUtil.toList(element);
    }
}